<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>
function doubleInsertOrderedList(s) {
     document.execCommand('insertOrderedList');
     document.execCommand('insertOrderedList');
}

test(() => assert_selection(
     '<div contenteditable><table><tr><td>|fsdf</td><td>fsdf</td></tr><tr><td>gghfg</td><td>fsfg</td></tr></table></div>',
     'insertOrderedList',
     '<div contenteditable><table><tbody><tr><td><ol><li>|fsdf</li></ol></td><td>fsdf</td></tr><tr><td>gghfg</td><td>fsfg</td></tr></tbody></table></div>'),
     'insertOrderedList - Insert list items in a single table cell.');

test(() => assert_selection(
     '<div contenteditable><table><tr><td>^fsdf</td><td>fsdf|</td></tr><tr><td>gghfg</td><td>fsfg</td></tr></table></div>',
     'insertOrderedList',
     '<div contenteditable><table><tbody><tr><td><ol><li>^fsdf</li></ol></td><td><ol><li>fsdf|</li></ol></td></tr><tr><td>gghfg</td><td>fsfg</td></tr></tbody></table></div>'),
     'insertOrderedList - Insert list items in all the cells of a table row.');

test(() => assert_selection(
     '<div contenteditable><table><tr><td>^fsdf</td><td>fsdf</td></tr><tr><td>gghfg</td><td>fsfg|</td></tr></table></div>',
     'insertOrderedList',
     '<div contenteditable><table><tbody><tr><td><ol><li>^fsdf</li></ol></td><td><ol><li>fsdf</li></ol></td></tr><tr><td><ol><li>gghfg</li></ol></td><td><ol><li>fsfg|</li></ol></td></tr></tbody></table></div>'),
     'insertOrderedList - Insert list items in all the cells of a table.');

test(() => assert_selection(
     '<div contenteditable>^<table><tr><td>fsdf</td><td>fsdf</td></tr><tr><td>gghfg</td><td>fsfg</td></tr></table>|</div>',
     'insertOrderedList',
     '<div contenteditable><ol><li>^<table><tbody><tr><td>fsdf</td><td>fsdf</td></tr><tr><td>gghfg</td><td>fsfg</td></tr></tbody></table>|</li></ol></div>'),
     'insertOrderedList - Insert a list item in a table.');

test(() => assert_selection(
     '<div contenteditable><table><tr><td>|fsdf</td><td>fsdf</td></tr><tr><td>gghfg</td><td>fsfg</td></tr></table></div>',
     'doubleInsertOrderedList',
     '<div contenteditable><table><tbody><tr><td>|fsdf</td><td>fsdf</td></tr><tr><td>gghfg</td><td>fsfg</td></tr></tbody></table></div>'),
     'doubleInsertOrderedList - Exec insertOrderedList twice in a single cell of a table row does not change the editable area at all.');

test(() => assert_selection(
     '<div contenteditable><table><tr><td>^fsdf</td><td>fsdf|</td></tr><tr><td>gghfg</td><td>fsfg</td></tr></table></div>',
     'doubleInsertOrderedList',
     '<div contenteditable><table><tbody><tr><td>^fsdf</td><td>fsdf|</td></tr><tr><td>gghfg</td><td>fsfg</td></tr></tbody></table></div>'),
     'doubleInsertOrderedList - Exec insertOrderedList twice in all the cells of a table row does not change the editable area at all.');

test(() => assert_selection(
     '<div contenteditable><table><tr><td>^fsdf</td><td>fsdf</td></tr><tr><td>gghfg</td><td>fsfg|</td></tr></table></div>',
     'doubleInsertOrderedList',
     '<div contenteditable><table><tbody><tr><td>^fsdf</td><td>fsdf</td></tr><tr><td>gghfg</td><td>fsfg|</td></tr></tbody></table></div>'),
     'doubleInsertOrderedList - Exec insertOrderedList twice in all the cells of a table does not change the editable area at all.');

test(() => assert_selection(
     '<div contenteditable>^<table><tr><td>fsdf</td><td>fsdf</td></tr><tr><td>gghfg</td><td>fsfg</td></tr></table>|</div>',
     'doubleInsertOrderedList',
     '<div contenteditable>^<table><tbody><tr><td>fsdf</td><td>fsdf</td></tr><tr><td>gghfg</td><td>fsfg</td></tr></tbody></table>|</div>'),
     'doubleInsertOrderedList - Exec insertOrderedList twice in a table does not change the editable area at all.');

</script>
